package com.bjqg.bjqg01.bjqg.utils;

import android.content.Context;

import com.bjqg.greendao.DaoMaster;
import com.bjqg.greendao.DaoSession;

/**
 * Created by bjqg01 on 2017/12/15.
 */

public class GreendaoUtils {

//    private final Context context;

////    private static GreendaoUtils mInstance;
//
//    public GreendaoUtils(Context context) {
//        this.context = context;
//    }
//
////    public static GreendaoUtils getInstance(Context context) {
////        if (mInstance == null) {
////            synchronized (GreendaoUtils.class) {
////                if (mInstance == null) {
////                    mInstance = new GreendaoUtils(context);
////                }
////            }
////        }
////        return mInstance;
////    }

    /**
     *
     * @param context
     * @return
     */
    public static DaoSession getDaoSession(Context context ,String dbname) {
        DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(context, dbname, null);
        DaoMaster daoMaster = new DaoMaster(devOpenHelper.getWritableDb());
        DaoSession daoSession = daoMaster.newSession();
        return daoSession;
    }
}
